<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>

<!DOCTYPE html>
<html lang="zh-cn">
<head>

    <title>文件管理</title>
    <%@include file="/WEB-INF/jsp/common/meta2.jsp" %>

</head>
<body class="content-body">
<div class="container-fluid">
    <table class="table table-responsive table-bordered">
        <tr>
            <th colspan="8" class="bg-info text-center">内容列表</th>
        </tr>
        <tr>
            <td colspan="8">

                <form id="listForm" action="${ctx}/common/file/list" method="get" class="form-inline" role="form">
                    <input type="hidden" name="pageNo" id="pageNo" value="${pageData.pagination.pageNo}"/>
                    <input type="hidden" name="pageSize" id="pageSize" value="10"/>
                    <input type="hidden" name="ascDesc" id="ascDesc" value="${pageData.ascDesc}"/>
                    <input type="hidden" name="orderName" id="orderName" value="${pageData.orderName}"/>

                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon">文件名|类型：</div>
                            <input type="text" name="LIKE_S&original_OR_suffix" placeholder="文件名、类型"
                                   value="${pageData.webMap['LIKE_S&original_OR_suffix'][0]}"
                                   class="form-control input-sm" placeholder="文件名|类型">
                        </div>
                    </div>
                    <input type="button" onclick="search()" value="查询" class="btn btn-info btn-sm">

                    <input onclick="location.href = '${ctx}/common/file/upload';"
                           class="btn btn-info pull-right btn-sm" type="button"
                           value="上传文件"/>
                </form>
            </td>
        </tr>
        <tr class="bg-info">
            <th>#</th>
            <th onclick="sort('original')">
                文件名称
            </th>
            <th onclick="sort('suffix')">
                类型
            </th>
            <th onclick="sort('insert_time')">
                上传时间
            </th>
            <th onclick="sort('size')">
                文件大小
            </th>
            <th class="text-center">操作</th>
        </tr>
        <tbody>
        <c:forEach var="entity" items="${pageData.result}" varStatus="index">
            <tr>
                <td>
                        ${index.index + 1}
                </td>
                <td>${entity.original}</td>
                <td>${entity.suffix}</td>
                <td>${entity.insertTime}</td>
                <td>
                    <fmt:formatNumber value="${entity.size/1024/1024}" pattern="##.##"
                                      minFractionDigits="2"></fmt:formatNumber> MB
                </td>
                <td class="text-center">
                    <a href="javascript:doDelete('${ctx}/common/file/delete/${entity.id}');">删除</a>
                    |
                    <a title="下载" href="${ctx}/common/file/download/${entity.id}">下载</a>
                    |
                    <a title="二维码" target="_blank" href="${ctx}/common/file/qr/${entity.id}">二维码</a>
                    |
                    <a title="预览" target="_blank" href="${ctx}/common/file/doctopdf/${entity.id}">转换到pdf</a>
                </td>
            </tr>
        </c:forEach>
        <c:if test="${fn:length(pageData.result) < 1}">
            <tr>
                <td colspan="8">暂无数据...</td>
            </tr>
        </c:if>

        </tbody>
    </table>
    <%@include file="/WEB-INF/jsp/common/pager.jsp" %>
</div>
</body>
</html>

<script>

    function doDelete(url) {
        if (confirm("确定执行该操作？")) {
            location.href = url;
        }
    }


</script>